class parseObject
	
	public rawPageData, startIndex
	public dataList
	
	public property let rawPage(rp)
		me.rawPageData=rp
		startIndex=1
	end property
	
	public property get rawPage
		rawPage=rawPageData
	end property
	
	public default function init(pageData)
		me.rawPageData=pageData
		set init = me
	end function

	private sub class_Initialize()
		startIndex=1
	end sub

	public sub start(searchTo)
		startIndex=inStr(1,rawPageData,searchTo)
	end sub

	public function item(index)
		item=dataList(index)
	end function
	
	public function result()
		result=dataList(0)
	end function

	'Exclusive. Doesn't include the values to search for in returned string.
	public sub extract(startText,endText)
		set data=CreateObject("Scripting.Dictionary")
		index=0
		do while hasNextValue(startText)
			index=index+1
			nextVal=getNextValue(startText,endText)
			data.add index,nextVal
		loop	
		dataList=data.items
	end sub
	
		
	public function getNextValue(leftSide,rightSide)
		'Search from the start until we find the "leftSide" bracket text.
		leftFunctionPointer=inStr(startIndex,rawPageData,leftSide)
		leftPointerOffset=len(leftSide)
		'Search from the occourance of "leftSide" until we find the "rightSide" bracket text.
		rightFunctionPointer=inStr(leftFunctionPointer,rawPageData,rightSide)
		rightPointerOffset=len(rightSide)
		'Calculate the length of the string we're cutting out.
		stringLength=rightFunctionPointer-(leftFunctionPointer+leftPointerOffset)'+rightPointerOffset
		'Add it to the startIndex
		startIndex=leftFunctionPointer+stringLength
		'Cut out the text between the textual bracket's
		getNextValue=mid(rawPageData,leftFunctionPointer+leftPointerOffset,stringLength)
	end function

	public function hasNextValue(searchTo)
		hasNextValue=(inStr(startIndex,rawPageData,searchTo)>0)	
	end function
end class